import { defHttp } from '@/utils/http/axios';
import { GrowCardItem, LineData, PieItem, TopItem } from './model/data';

enum Api {
  DASHBOARD_CARD = '/dashboard/growCards',
  DASHBOARD_PV = '/dashboard/statPV',
  DASHBOARD_PV_SOURCE = '/dashboard/statPvSource',
  DASHBOARD_PV_TOP = '/dashboard/statPvTop',
}

/**
 * @description: Get sample list value
 */

export const dashboardCardApi = () =>
  defHttp.post<GrowCardItem[]>({
    url: Api.DASHBOARD_CARD,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const dashboardPVApi = (start: string, end: string) =>
  defHttp.get<LineData>({
    url: Api.DASHBOARD_PV,
    params: { start: start, end: end },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const dashboardPVSourceApi = (start: string, end: string) =>
  defHttp.get<PieItem[]>({
    url: Api.DASHBOARD_PV_SOURCE,
    params: { start: start, end: end },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const dashboardPVTopApi = (type: string, start: string, end: string) =>
  defHttp.get<TopItem[]>({
    url: Api.DASHBOARD_PV_TOP,
    params: { type: type, start: start, end: end },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
